//
//  OrderDetailViewController.m
//  LvBao
//
//  Created by 范琦 on 16/6/6.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "OrderDetailViewController.h"
#import "OrderDetailTopCell.h"
#import "OrderDetailCell.h"
#import "ScanCodeSectionCell.h"

@interface OrderDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation OrderDetailViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];

    self.title = @"订单详情";
    [self creatTableView];
}

- (void)creatTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT) style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [_tableView registerNib:[UINib nibWithNibName:@"OrderDetailTopView" bundle:nil] forCellReuseIdentifier:@"cell1"];
    [_tableView registerNib:[UINib nibWithNibName:@"OrderDetailCell" bundle:nil] forCellReuseIdentifier:@"cell2"];
    [_tableView registerNib:[UINib nibWithNibName:@"ScanCodeSectionCell" bundle:nil] forCellReuseIdentifier:@"cell3"];

    _tableView.sectionFooterHeight = 0;
    _tableView.backgroundColor = [UIColor huiseColor];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else if (section == 1){
        return 6;
    }
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 100;
    }else if (indexPath.section == 1){
        return 40;
    }else{
        return 40;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        OrderDetailTopCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    else if (indexPath.section == 1){
        OrderDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        if (indexPath.row == 0) {
            cell.titleLabel.text = @"订单号:89456235";
            cell.numberLabel.text = @"2016-06-02";
        }
        if (indexPath.row == 1) {
            ScanCodeSectionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell3"];
            cell.titleLabel.text = @"电子垃圾";
            
            cell.rightImage.image = nil;
            return cell;
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        return cell;
    }
    else{
        OrderDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
            cell.titleLabel.text = @"";
            cell.numberLabel.text = @"合计25件     580积分";
        cell.numberLabel.alpha = 1;
        cell.numberLabel.font = [UIFont systemFontOfSize:15];
        cell.numberLabel.textColor = [UIColor blackColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        return cell;
    }

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
